// 分页组件的再封装
<template>
  <div class="x-pagination">
    <el-divider v-if="pageInfo.total - pageInfo.pageSize > 0"></el-divider>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageInfo.currentPage"
      :page-sizes="pageSizes"
      :page-size="pageInfo.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageInfo.total"
      hide-on-single-page
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  props: {
    // 条数分类
    pageSizes: {
      type: Array,
      default: () => [10, 20, 30, 40],
    },
    pageInfo: {
      type: Object,
      require: true,
      default: () => {},
    },
  },
  methods: {
    handleCurrentChange(newVal) {
      this.pageInfo.currentPage = newVal;
      this.$emit("handleCurrentChange", newVal);
    },
    handleSizeChange(newVal) {
      this.pageInfo.pageSize = newVal;
      this.$emit("handleSizeChange", newVal);
    },
  },
};
</script>

<style lang="scss">
.x-pagination {
  .el-pagination {
    display: flex;
    justify-content: flex-end;
  }
}
</style>
